<?php

class Log {

    public static function logData( $log, $file )
    {
    	file_put_contents($file, '['.date('Y-m-d H:i:s').'] ' . $log . "\r\n", FILE_APPEND | LOCK_EX);
    }

    public static function logBegin( $log )
    {
        self::logData( "Begin : $log", self::getLogDir());
    }

    public static function logInfo( $log )
    {
        self::logData( "Info : $log", self::getLogDir());
    }

    public static function logWarning( $log )
    {
        self::logData( "Warning : $log", self::getLogDir());
    }

    public static function logError( $log )
    {
        self::logData( "Error : $log", self::getLogDir());
    }

    public static function logSuccess( $log )
    {
        self::logData( "Success : $log", self::getLogDir());
    }

    private static function getLogDir() {
    	$filepath=dirname(__FILE__) . "/../../app.log";
    	if (realpath($filepath))
    		return realpath($filepath);
    	return $filepath;
    }
}